package com.ds.admin.console.controller;

import com.ds.admin.console.param.TFileParam;
import com.ds.admin.console.service.TFileService;
import com.ds.admin.console.vo.TFileVo;
import com.ds.common.web.request.PageParam;
import com.ds.common.web.response.PageInfo;
import com.ds.common.web.response.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 文件上传记录控制器
 *
 * @author fusheng
 * @since 2024-09-10
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tFile")
public class TFileController {

	private final TFileService tFileService;

	/**
	 * 新增
	 * @param param 参数
	 * @return 主键ID
	 */
	@PostMapping("/insert")
	public Result<Long> insert(@Validated @RequestBody TFileParam param) {
		return Result.success(tFileService.insert(param));
	}

	/**
	 * 修改
	 * @param param 参数
	 * @return 主键ID
	 */
	@PostMapping("/update")
	public Result<Long> update(@Validated @RequestBody TFileParam param) {
		return Result.success(tFileService.update(param));
	}

	/**
	 * 删除
	 * @param id 主键ID
	 * @return 主键ID
	 */
	@GetMapping("/delete/{id}")
	public Result<Long> delete(@PathVariable Long id) {
		return Result.success(tFileService.delete(id));
	}

	/**
	 * 单个查询
	 * @param id 主键ID
	 * @return 返回值
	 */
	@GetMapping("/select/{id}")
	public Result<TFileVo> select(@PathVariable Long id) {
		return Result.success(tFileService.select(id));
	}

	/**
	 * 列表查询
	 * @param param 参数
	 * @return 返回值
	 */
	@PostMapping("/list")
	public Result<PageInfo<TFileVo>> list(@RequestBody PageParam<TFileParam> param) {
		return Result.success(tFileService.selectPage(param));
	}

}
